package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.SpecialBannerRequest;
import com.ytjj.qmyx.admin.service.SpecialBannerService;
import com.ytjj.qmyx.mall.model.SpecialBanner;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 *
 * @Version: 1.0
 *
 * 首页-banner 模块
 */
@RestController
@RequestMapping("/specialBanner")
public class SpecialBannerController {

	@Resource
	private SpecialBannerService specialBannerService;

	@GetMapping("/getSpecialList")
	@OperLog(operModule = "首页Banner模块", operDesc = "mall专区列表", operType = SysLogConstants.OPERATION_SELECT)
	public CommonResult getSpecialList() {
		return CommonResult.success(specialBannerService.getSpecialList());
	}

	@GetMapping("/getSpecialDynamicList")
	@OperLog(operModule = "首页Banner模块", operDesc = "Dynamic专区列表", operType = SysLogConstants.OPERATION_SELECT)
	public CommonResult getSpecialDynamicList() {
		return CommonResult.success(specialBannerService.getSpecialDynamicList());
	}

	@PostMapping("/list")
	@OperLog(operModule = "首页Banner模块", operDesc = "列表", operType = SysLogConstants.OPERATION_SELECT)
	public CommonResult getSpeBannerList(@RequestBody SpecialBannerRequest request) {
		return CommonResult.success(specialBannerService.getSpeBannerList(request));
	}

	@PostMapping("/insert")
	@OperLog(operModule = "首页Banner模块", operDesc = "新增", operType = SysLogConstants.OPERATION_ADD)
	public CommonResult insertSpeBanner(@RequestBody SpecialBanner specialBanner) {
		return CommonResult.success(specialBannerService.insertSpeBanner(specialBanner));
	}

	@PostMapping("/update")
	@OperLog(operModule = "首页Banner模块", operDesc = "修改", operType = SysLogConstants.OPERATION_UPDATE)
	public CommonResult updateSpeBanner(@RequestBody SpecialBanner specialBanner) {
		return CommonResult.success(specialBannerService.updateSpeBanner(specialBanner));
	}

	@GetMapping("/delete")
	@OperLog(operModule = "首页Banner模块", operDesc = "删除", operType = SysLogConstants.OPERATION_DELETE)
	public CommonResult deleteSpeBanner(@RequestParam Integer id) {
		return CommonResult.success(specialBannerService.deleteSpeBanner(id));
	}

	@GetMapping("/getSubjectList")
	public CommonResult getSubjectList() {
		return specialBannerService.getSubjectList();
	}
}
